<?php

namespace Budget\BudgetBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Table(name="expenses")
 * @ORM\Entity(repositoryClass="Budget\BudgetBundle\Repository\ExpenseRepository")
 */
class Expense
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @Assert\NotBlank()
     * @ORM\Column(type="decimal", precision=10, scale=2)
     */
    protected $price;
    
    /**
     * @Assert\NotBlank()
     * @ORM\ManyToOne(targetEntity="Category", inversedBy="expenses")
     * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
     */
    protected $category;

    /**
     * @Assert\NotBlank()
     * @ORM\Column(type="datetime")
     */
    protected $date_created;
    
    /**
     * @Assert\NotBlank()
     * @ORM\Column(type="date")
     */
    protected $date;

    /**
     * @ORM\ManyToOne(targetEntity="User", inversedBy="expenses")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
     */
    protected $user;
            
    /**
     * @ORM\Column(type="string", length=400, nullable=true)
     */
    protected $comment;
    
    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    protected $date_deleted;
    
    /**
     * @ORM\ManyToOne(targetEntity="User")
     * @ORM\JoinColumn(name="deleted_by", referencedColumnName="id")
     */
    protected $deleted_by;
    
    /**
     * @ORM\ManyToOne(targetEntity="User")
     * @ORM\JoinColumn(name="created_by", referencedColumnName="id")
     */
    protected $created_by;
    
   
    public function __construct()
    {
        $this->setDateCreated(new \DateTime());
        //$this->setDateDeleted(null);
    }
    

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set price
     *
     * @param string $price
     * @return Expense
     */
    public function setPrice($price)
    {
        $this->price = $price;

        return $this;
    }

    /**
     * Get price
     *
     * @return string 
     */
    public function getPrice()
    {
        return $this->price;
    }



    /**
     * Set comment
     *
     * @param string $comment
     * @return Expense
     */
    public function setComment($comment)
    {
        $this->comment = $comment;

        return $this;
    }

    /**
     * Get comment
     *
     * @return string 
     */
    public function getComment()
    {
        return $this->comment;
    }

    /**
     * Set user
     *
     * @param \Budget\BudgetBundle\Entity\User $user
     * @return Expense
     */
    public function setUser(\Budget\BudgetBundle\Entity\User $user = null)
    {
        $this->user = $user;

        return $this;
    }

    /**
     * Get user
     *
     * @return \Budget\BudgetBundle\Entity\User 
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * Set category
     *
     * @param \Budget\BudgetBundle\Entity\Category $category
     * @return Expense
     */
    public function setCategory(\Budget\BudgetBundle\Entity\Category $category = null)
    {
        $this->category = $category;

        return $this;
    }

    /**
     * Get category
     *
     * @return \Budget\BudgetBundle\Entity\Category 
     */
    public function getCategory()
    {
        return $this->category;
    }

    /**
     * Set deleted_by
     *
     * @param \Budget\BudgetBundle\Entity\User $deletedBy
     * @return Expense
     */
    public function setDeletedBy(\Budget\BudgetBundle\Entity\User $deletedBy = null)
    {
        $this->deleted_by = $deletedBy;

        return $this;
    }

    /**
     * Get deleted_by
     *
     * @return \Budget\BudgetBundle\Entity\User 
     */
    public function getDeletedBy()
    {
        return $this->deleted_by;
    }


    /**
     * Set date_created
     *
     * @param \DateTime $dateCreated
     * @return Expense
     */
    public function setDateCreated($dateCreated)
    {
        $this->date_created = $dateCreated;

        return $this;
    }

    /**
     * Get date_created
     *
     * @return \DateTime 
     */
    public function getDateCreated()
    {
        return $this->date_created;
    }

    /**
     * Set date_deleted
     *
     * @param \DateTime $dateDeleted
     * @return Expense
     */
    public function setDateDeleted($dateDeleted)
    {
        $this->date_deleted = $dateDeleted;

        return $this;
    }

    /**
     * Get date_deleted
     *
     * @return \DateTime 
     */
    public function getDateDeleted()
    {
        return $this->date_deleted;
    }

    /**
     * Set created_by
     *
     * @param \Budget\BudgetBundle\Entity\User $createdBy
     * @return Expense
     */
    public function setCreatedBy(\Budget\BudgetBundle\Entity\User $createdBy = null)
    {
        $this->created_by = $createdBy;

        return $this;
    }

    /**
     * Get created_by
     *
     * @return \Budget\BudgetBundle\Entity\User 
     */
    public function getCreatedBy()
    {
        return $this->created_by;
    }
    
    public function addExpenses(Expenses $expenses)
    {
        if (!$this->expenses->contains($expenses)) {
            $this->expenses->add($expenses);
        }
    }


    /**
     * Set date
     *
     * @param \DateTime $date
     * @return Expense
     */
    public function setDate($date)
    {
        $this->date = $date;

        return $this;
    }

    /**
     * Get date
     *
     * @return \DateTime 
     */
    public function getDate()
    {
        return $this->date;
    }
}
